﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
 CodeBehind="Tournament.aspx.cs" Inherits="Nivdal.Tournament" Theme="SkinFile"  %>
 
<%@ Register Assembly="obout_Flyout2_NET" Namespace="OboutInc.Flyout2" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
    <script language="javascript" type="text/javascript">
        function PrizesCheck(Id) {
            var radios = document.getElementsByTagName("input");
            for (i = 0; i < radios.length; i++) {
                if ((radios[i].type == "radio") && (radios[i].name.match("PrizesSets"))) {
                    var match_str = "ctl0" + Id + "_SelectedRB";
                    if (!radios[i].id.match(match_str)) {
                        radios[i].checked = false;
                    }
                }
            }

        }

        function GeneratePassword() {
            var pwd = Math.floor(Math.random() * 900000) + 100000;
            $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_TournamentFormView_TournamentPasswordTextBox").val(pwd);
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
     <Triggers>
        <asp:PostBackTrigger ControlID="TournamentFormView$SignupButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$SignOutButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$StartTournamentButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$SetPrizesSetButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$AddTournamentDirectorButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$SetPasswordButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$ApprovedTeamsRepeater" />
        <asp:PostBackTrigger ControlID="TournamentFormView$ApproveSelectedButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$DeclineSelectedButton" />
        <asp:PostBackTrigger ControlID="TournamentFormView$DeleteTournamentButton" />
    </Triggers>


    <ContentTemplate>
        <asp:HiddenField ID="TournamentTypeHiddenField" runat="server" />

        <asp:Panel ID="MessagePanel" runat="server" Visible="false">
        <div class="basic_element">
            <asp:Label ID="MessageLabel" runat="server" SkinID="GreenSmallHeaderLabel"></asp:Label>
        </div>
        </asp:Panel>
        <asp:HiddenField ID="TournamentIdHiddenField" runat="server" />
        <asp:FormView ID="TournamentFormView" runat="server" DataSourceID="TournamentInfoDataSource" Width="100%" >
        <ItemTemplate>
            <div class="basic_element">
            <div class="red_title_no_padding">
            <div class="grey_title_inside_red floater">
               <asp:Label ID="TournamentTitleLabel" runat="server" Text='<%# Eval("TournamentName") %>' CssClass="white_title"></asp:Label>
            </div>
            <div class="grey_title_triangle floater"></div>
                <asp:HyperLink ID="TournamentForumLink" runat="server" NavigateUrl='<%# "~/ForumDetails.aspx?Id=" + Eval("ForumId") %>'
                 ImageUrl="~/Images/Icons/forum.png" ToolTip="<%$ Resources:Resource, Tournament_OfficialForumTitle %>"
                 Visible='<%# (Eval("ForumId").ToString() != "0") %>'></asp:HyperLink>
            </div>
            <div class="padding5 vectors_container">
            <asp:HiddenField ID="NationalTeamsHiddenField" runat="server" Value='<%# Eval("IsNationalTeams") %>' />
            <%--<asp:HiddenField ID="TournamentIdHiddenField" runat="server" Value='<%# Eval("TournamentId") %>' />--%>
            
            <br /><br />
            <asp:Panel ID="TournamentInfoPanel" runat="server">
                <table>
                <tr>
                <td><asp:Label ID="ExecutionStatusTitleLabel" runat="server" SkinID="InfoLabel" 
                Text="<%$ Resources:Resource, Tournament_TournamentStageTitle %>"></asp:Label> 
                       
                </td>
                <td><asp:Label ID="ExecutionStatusLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("ExecutionStatusName") %>'></asp:Label>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="TournamentSystemTitleLabel" runat="server" SkinID="InfoLabel" 
                    Text="<%$ Resources:Resource, Tournament_SystemTitle %>"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="TournamentSystemLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("TournamentTypeDescription") %>'></asp:Label>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="NumVacanciesLabel" runat="server" SkinID="InfoLabel"
                     Text="<%$ Resources:Resource, Tournament_NumPlacesInTournament %>"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="NumPlacesLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumTeams") %>'></asp:Label>
                </td>
                </tr>
                <tr>
                <td style="vertical-align:top;">
                    <asp:Label ID="SigedUpTitleLabel" runat="server" SkinID="InfoLabel" 
                     Text="<%$ Resources:Resource, Tournament_SignedTeams %>"></asp:Label>
                </td>
                <td>
                    <asp:Panel ID="SignedUpTeamsNumbers" runat="server" Visible='<%# (Eval("ExecutionStatus").ToString() == "1") %>'>
                        <table>
                        <tr>
                        <td>
                            <asp:Label ID="ApprovedStatusLabel" runat="server" SkinID="InfoLabel" Text='<%# Eval("ApprovedStatusText") %>'></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="ApprovedTeamsLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumApprovedTeams") %>'></asp:Label>
                        </td>
                        </tr>
                        <tr>
                        <td>
                            <asp:Label ID="AwaitingResponceTitleLabel" runat="server" SkinID="InfoLabel" Text='<%# Eval("AwaitingResponceStatusText") %>'></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="AwaitingResponceLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumAwaitingTeams") %>'></asp:Label>
                        </td>
                        </tr>
                        <tr>
                        <td>
                            <asp:Label ID="InWaitingListTitleLabel" runat="server" SkinID="InfoLabel" Text='<%# Eval("WaitingListStatusText") %>'></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="InWaitingListLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumWaitingListTeams") %>'></asp:Label>
                        </td>
                        </tr>
                        <tr>
                        <td>
                            <asp:Label ID="DeclinedTitleLabel" runat="server" SkinID="InfoLabel" Text='<%# Eval("DeclinedStatusText") %>'></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="DeclinedLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumDeclinedTeams") %>'></asp:Label>
                        </td>
                        </tr>
                        </table>
                    </asp:Panel>
                    <asp:Label ID="SignedUpNumTeamsLabel2" runat="server" SkinID="GridLabel"
                     Text='<%# Eval("NumApprovedTeams") %>' Visible='<%# (Eval("ExecutionStatus").ToString() != "1") %>'></asp:Label>
                </td>
                </tr>
                <tr>
                <td style="vertical-align:top;">
                    <asp:Label ID="DirectorsTitleLabel" runat="server" SkinID="InfoLabel"
                     Text="<%$ Resources:Resource, Tournament_DirectorsTitleLabel %>"></asp:Label>
                </td>
                <td>
                    <asp:Repeater ID="DirectorsRepeater" runat="server" DataSourceID="DirectorsDataSource">
                        <SeparatorTemplate>,</SeparatorTemplate>
                        <ItemTemplate>
                            <asp:HyperLink ID="UserHyperlink" runat="server" NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>'
                             Text='<%# Eval("UserName") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                        </ItemTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="DirectorsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentDirectors" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
                </tr>
                <tr>
                <td style="vertical-align:top;">
                    <asp:Label ID="TournamentPricesTitleLabel" runat="server" SkinID="InfoLabel"
                     Text="<%$ Resources:Resource, Tournament_TournamentPricesTitle %>"></asp:Label>
                </td>
                <td>
                    <asp:Repeater ID="PricesRepeater" runat="server" DataSourceID="TournamentPricesDataSource">
                    <ItemTemplate>
                    <div class="floater" style="text-align:center; padding:0px 5px 0px 5px;">
                        <asp:Label ID="PlaceLabel" runat="server" SkinID="SubHeaderLabel" Text='<%# "#" + Eval("Place") %>'></asp:Label>
                        <br />
                        <asp:Image ID="PriceImage" runat="server" ImageUrl='<%# Eval("Picture") %>' />
                        <br />
                        <asp:HyperLink ID="WinnerLink" runat="server" NavigateUrl='<%# TeamHomePageLink() + Eval("TeamId") %>'
                         SkinID="GreenTitleHyperLink" Text='<%# Eval("TeamName") %>' Visible='<%# Eval("TeamId").ToString() != "0" %>'></asp:HyperLink>

                    </div>
                    </ItemTemplate>
                    </asp:Repeater>
            
                    <asp:SqlDataSource ID="TournamentPricesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentPrices" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
                </tr>
                <tr>
                    <td style="vertical-align:top;">
                        <asp:Label ID="PremiumPrizesTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_PremiumPrizesTitle %>"
                         Visible='<%# Eval("IsNationalTeams").ToString() == "0" %>'></asp:Label>
                    </td>
                    <td>
                        <asp:Panel ID="PremiumPrizeInfoPanel" runat="server" Visible='<%# Eval("IsNationalTeams").ToString() == "0" %>'>
                        <asp:GridView ID="PremiumPrizesGridview" runat="server" SkinID="Professional" AllowPaging="false" AutoGenerateColumns="false" DataSourceID="PremiumPrizesDataSource">
                        <Columns>
                            <asp:TemplateField HeaderText="#">
                                <ItemTemplate>
                                    <asp:Label ID="PlaceLabel" runat="server" SkinID="SubHeaderLabel" Text='<%# "#" + Eval("Place") %>'></asp:Label>                                     
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="<%$ Resources:Resource, Tournament_PremiumPrizeTitle %>">
                                <ItemTemplate>
                                    <asp:Label ID="DaysLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("Days") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            <asp:Label ID="NoPremiumPrizesTitleLabel" runat="server" Text="<%$ Resources:Resource, Tournament_NoPremiumPrizesText %>" SkinID="GridLabel"></asp:Label>
                        </EmptyDataTemplate>
                        </asp:GridView>
                        <asp:SqlDataSource ID="PremiumPrizesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="Nivdal_GetTournamentPremiumPrizes" SelectCommandType="StoredProcedure">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <br />
                        <asp:HyperLink ID="DonateTournamentPrizeLink" runat="server" Text="<%$ Resources:Resource, Tournament_DonatePremium %>" SkinID="GreenTitleHyperLink"
                         NavigateUrl='<%# "~/Shop.aspx?TournamentId=" + Eval("TournamentId") %>'  Target="_blank" ></asp:HyperLink>
                        <asp:Image ID="DonationExplanationImage" runat="server" ImageUrl="~/Images/question.gif" />
                        <cc1:Flyout ID="DonationExplanationFlyout" AttachTo="DonationExplanationImage" NoneEffect="true" runat="server">
                            <div class="ToolTipStyle" style="width:250px;">
                                <asp:Label ID="DonationExplanationLabel" runat="server" Text="<%$ Resources:Resource, Tournament_DonatePremiumExplanation %>"></asp:Label>                        
                            </div>
                        </cc1:Flyout>
                        </asp:Panel>
                    </td>
                </tr>
                </table>
                <br />


                <asp:Label ID="DatesTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_DatesTitle %>"></asp:Label>
                <br />
                <table cellpadding="5">
                <tr>
                <td style="vertical-align:top;">
                    <asp:GridView ID="TournamentDatesGridview" runat="server" SkinID="Professional" AutoGenerateColumns="false"
                     DataSourceID="TournamentDatesDataSource" OnRowDataBound="DatesRowDataBind">
                     <Columns>
                     <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_TournamentStage %>">
                        <ItemTemplate>
                            <asp:HiddenField ID="StageNameHiddenField" runat="server" Value='<%# Eval("StageType") %>'></asp:HiddenField>
                            <asp:HiddenField ID="StageIdHiddenfield" runat="server" Value='<%# Eval("StageId") %>' />
                            <asp:HiddenField ID="AvailabilityHiddenField" runat="server" Value='<%# Eval("Available") %>' />
                            <asp:HiddenField ID="SpecialNameHiddenField" runat="server" Value='<%# Eval("SpecialName") %>' />
                            
                            <asp:Label ID="StageRoundLabel" runat="server" SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Date %>">
                        <ItemTemplate>
                            <asp:Label ID="DateLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("Date") %>'></asp:Label>
                        </ItemTemplate>
                     </asp:TemplateField>
                     </Columns>
                     </asp:GridView> 
                     
                </td>
                <td style="vertical-align:top;">
                    <asp:Panel ID="FriendlyWeeksPanel" runat="server" Visible='<%# (Eval("IsNationalTeams").ToString() == "0") && (!(bool)Eval("CanSignOut")) && (Eval("ExecutionStatus").ToString() == "1") %>'>
                        <asp:GridView ID="TournamentWeeksGridview" runat="server"  SkinID="Professional" AutoGenerateColumns="false"
                         DataSourceID="FriendlyWeeksDataSource" OnRowDataBound="FriendlyWeeksDataBound">
                        <Columns>
                            <asp:TemplateField HeaderText="<%$ Resources:Resource, Friendly_FriendlyWeeksTitleLabel %>">
                                <ItemTemplate>
                                    <asp:Label ID="WeekDatesLabel" runat="server" SkinID="GridLabel" 
                                     Text='<%# Eval("StartDate") + " - " + Eval("EndDate") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="#">
                                <ItemTemplate>
                                    <asp:HiddenField ID="NumTournamentGamesHF" runat="server" Value='<%# Eval("NumTournamentDates") %>' />
                                    <asp:HiddenField ID="NumBookedDatesHF" runat="server" Value='<%# Eval("NumBookedDates") %>' />
                                    <asp:Label ID="NumGamesLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("NumTournamentDates") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        </asp:GridView>
                        
                    </asp:Panel>
                </td>
                </tr>
                </table>
                <br /><br />
            </asp:Panel>
            <asp:Panel ID="TournamentTablesPanel" runat="server" Visible='<%# ((Eval("ExecutionStatus").ToString() == "2") || (Eval("ExecutionStatus").ToString() == "3")) %>'>
                <asp:Panel ID="LeagueTournamentPanel" runat="server" Visible='<%# Eval("TournamentType").ToString() == "1" %>'>
                   <asp:FormView ID="LeagueRoundsInfoFormView" runat="server" DataSourceID="LeagueOrCupStageAdditionalInfoDataSource" Width="100%" >
                   <ItemTemplate>
                        <asp:HiddenField ID="LeagueGroupIdHiddenField" runat="server" Value='<%# Eval("GroupId") %>' />
                        <asp:GridView runat="server" ID="LeagueTableGrid" AutoGenerateColumns="false" DataSourceID="TournamentLeagueTableDataSource"
                        SkinID="Professional">
                        <Columns>
                            <asp:TemplateField ItemStyle-Width="10%">
                                <ItemTemplate>
                                    <asp:Label ID="N" runat="server" Text='<%# Eval("Position")%>' SkinID="GridLabel"> </asp:Label>                   
                                </ItemTemplate>
                            </asp:TemplateField>
                                <asp:TemplateField ItemStyle-Width="40%">
                                <HeaderTemplate>
                                    <asp:Label ID="TeamNameLabel" ToolTip="<%$ Resources:Resource, league_TeamNameLabelToolTip %>" runat="server" Text="<%$ Resources:Resource, Global_TeamName %>"></asp:Label>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:HyperLink ID="TeamLink" runat="server" Text='<%# Eval("TeamName") %>' SkinID="BlackHyperLinkSkin"
                                        NavigateUrl='<%# TeamHomePageLink() + Eval("TeamId") %>'></asp:HyperLink>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="10%">
                                <HeaderTemplate>
                                    <asp:Label ID="GamesTitleLabel" ToolTip="<%$ Resources:Resource, Global_Games %>" runat="server" Text="<%$ Resources:Resource, Global_GamesHeader %>"></asp:Label>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="GamesLabel" runat="server" Text='<%# Eval("Round")%>' SkinID="GridLabel"> </asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="10%">
                                <HeaderTemplate>
                                    <asp:Label ID="PointLabel" ToolTip="<%$ Resources:Resource, Global_Points %>" runat="server" Text="<%$ Resources:Resource, league_PointLabel %>"></asp:Label>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Points")%>' SkinID="GridLabel"> </asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="20%">
                                <HeaderTemplate>
                                    <asp:Label ID="GoalsLabel" ToolTip="<%$ Resources:Resource, Global_Goals %>" runat="server" Text="<%$ Resources:Resource, Global_GoalsHeader %>"></asp:Label>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" SkinID="GridLabel"
                                        Text='<%# Eval("GoalsScored").ToString() + " - " + Eval("GoalsAgainst").ToString() %>' ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns> 
                        </asp:GridView>
                        <asp:SqlDataSource ID="TournamentLeagueTableDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                            SelectCommand="Nivdal_GetTournamentStageGroupTable" SelectCommandType="StoredProcedure">   
                            <SelectParameters>
                                <asp:ControlParameter ControlID="LeagueGroupIdHiddenField" Name="GroupId" PropertyName="Value"  />
                            </SelectParameters>                     
                        </asp:SqlDataSource>
                    <br /><br />
                    <asp:HyperLink ID="AllLeagueMatchesLink" runat="server" Text="<%$ Resources:Resource, league_FixturesPageLinkButton %>"
                     SkinID="GreenTitleHyperLink" NavigateUrl='<%# "~/TournamentGroup.aspx?Id=" + Eval("GroupId") %>'></asp:HyperLink>
                    <table style="width:100%;" cellpadding="5">
                    <tr>
                    <td>
                        <asp:Panel ID="NextRoundPanel" runat="server" Visible='<%# Eval("NextStageDate").ToString().Length > 0 %>'>
                            <asp:Label ID="NextRoundLabel" runat="server" SkinID="InfoLabel"
                            Text='<%# (bool)Eval("IsOngoing") ? Resources.Resource.league_OngoingMatchesTitleLabel : Resources.Resource.league_NextRoundLabel %>' ></asp:Label>
                            <asp:Label ID="NextRoundMatchesDateLabel" runat="server" SkinID="InfoLabel" Text='<%# " (" + Eval("NextStageDate") + ")" %>' ></asp:Label>
                            <br />
                            <asp:GridView ID="NextRoundMatcheGridview" runat="server" SkinID="Professional" DataSourceID="NextRoundMatchesSqlDataSource" AutoGenerateColumns="false"
                             OnRowCommand="NextRoundMatchesCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Match %>">
                                    <ItemTemplate>
                                        <asp:Hyperlink ID="LinkButton1" runat="server" Text='<%# Eval("title") %>' SkinID="BlackHyperLinkSkin"
                                        NavigateUrl='<%# Eval("Id", "MatchPage.aspx?MatchId={0}") %>'></asp:Hyperlink>                        
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:ImageButton ID="AddToliveImageButton" runat="server" CommandName="AddToLive" CommandArgument='<%# Eval("Id") %>'
                                         ToolTip="<%$ Resources:Resource, Live_AddMatchToLiveText %>" ImageUrl="~/Images/Icons/LiveDetails.png" Visible='<%# IsAllowedLive(Eval("CanAddToLive")) %>' />
                                        <asp:ImageButton ID="BookmarkMatchButton" runat="server" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/bookmarks.png"
                                         CommandName="Bookmark" ToolTip="<%$ Resources:Resource, MatchPage_BookmarkLinkButtonToolTip %>" Visible='<%# IsPremium() %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <EmptyDataTemplate>
                                <asp:Label ID="NoMatchesWereScheduledLabel" runat="server" Text="<%$ Resources:Resource, league_NoMatchesWereScheduledLabel %>" SkinID="InfoLabel"></asp:Label>
                            </EmptyDataTemplate>
                            </asp:GridView>
                            <asp:SqlDataSource ID="NextRoundMatchesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="Nivdal_ShowTournamentGroupNextRoundMatches" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="LeagueGroupIdHiddenField" Name="GroupId" PropertyName="Value"  />
                                </SelectParameters>     
                            </asp:SqlDataSource>
                        </asp:Panel>                        
                    </td>    
                    <td>
                        <asp:Panel ID="LastRoundPanel" runat="server" Visible='<%# Eval("PreviousStageDate").ToString().Length > 0 %>'>
                            <asp:Label ID="LastRoundLabel" runat="server" Text="<%$ Resources:Resource, league_LastRoundLabel %>" SkinID="InfoLabel"></asp:Label>
                            <br />
                            <asp:GridView ID="LastRoundGridview" runat="server" AutoGenerateColumns="false" SkinID="Professional"
                             DataSourceID="LastRoundMatchesDataSource">
                                <Columns>
                                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Match %>">
                                        <ItemTemplate>
                                            <asp:Hyperlink ID="LinkButton1" runat="server" Text='<%# Eval("Title") %>' 
                                             NavigateUrl='<%# Eval("Id", "MatchPage.aspx?MatchId={0}") %>' SkinID="BlackHyperLinkSkin"></asp:Hyperlink>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Result %>">
                                        <ItemTemplate>
                                            <asp:Label ID="ResultLabel" runat="server" Text='<%# Eval("Result") %>' SkinID="GridLabel"/>
                                         </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EmptyDataTemplate>
                                    <asp:Label ID="NoMatchesLabel" runat="server" Text="<%$ Resources:Resource, league_NoMatchesLabel %>" SkinID="InfoLabel"></asp:Label>
                                </EmptyDataTemplate>
                            </asp:GridView>
                            <asp:SqlDataSource ID="LastRoundMatchesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="Nivdal_ShowTournamentGroupLastRoundMatches" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="LeagueGroupIdHiddenField" Name="GroupId" PropertyName="Value" />
                                </SelectParameters>     
                            </asp:SqlDataSource>
                        </asp:Panel>
                    </td>
                    </tr>
                    </table>
                    </ItemTemplate>
                    </asp:FormView>
                    
                </asp:Panel>
                 <asp:Panel ID="CupTournamentPanel" runat="server" Visible='<%# Eval("TournamentType").ToString() == "2" %>'>
                    <asp:FormView ID="CupTournamentInforFormview" runat="server" DataSourceID="LeagueOrCupStageAdditionalInfoDataSource">
                    <ItemTemplate>
                        <asp:HiddenField ID="StageIdHiddenField" runat="server" Value='<%# Eval("StageId") %>' />
                        <asp:HiddenField ID="CupGroupIdHiddenField" runat="server" Value='<%# Eval("GroupId") %>' />
                        <asp:Repeater ID="RoundsRepeater" runat="server" DataSourceID="CupStageRoundsDataSource">
                            <ItemTemplate>
                                <asp:Label ID="RoundDateLabel" runat="server" SkinID="GridLabel"
                                        Text='<%# RoundLabelText(Eval("RoundNumber").ToString(), Eval("Date").ToString(), Eval("SpecialName").ToString()) %>'></asp:Label>
                                <asp:HiddenField ID="RoundHiddenField" runat="server" Value='<%# Eval("RoundNumber") %>' />
                                <br />
                                <asp:GridView ID="RoundMatchesGridview" runat="server" DataSourceID="TournamentRoundMatches"
                                    AutoGenerateColumns="false" SkinID="Professional">
                                    <Columns>
                                        <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:HyperLink ID="MatchLink" runat="server" SkinID="BlackHyperLinkSkin" Text='<%# Eval("MatchTitle") %>'
                                                NavigateUrl='<%# "~/MatchPage.aspx?MatchId=" + Eval("MatchId") %>'></asp:HyperLink>
                                        </ItemTemplate>
                                        </asp:TemplateField>                                            
                                        <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="ResultLabel" SkinID="GridLabel" Text='<%# Eval("Result") %>'></asp:Label>
                                        </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                                <asp:SqlDataSource ID="TournamentRoundMatches" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                    SelectCommand="Nivdal_GetTournamentStageRoundMatches" SelectCommandType="StoredProcedure">   
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="CupGroupIdHiddenField" Name="GroupId" PropertyName="Value" />
                                        <asp:ControlParameter ControlID="RoundHiddenField" Name="Round" PropertyName="Value" />
                                    </SelectParameters>                     
                                </asp:SqlDataSource>
                            </ItemTemplate>
                            <SeparatorTemplate><br /></SeparatorTemplate>
                        </asp:Repeater>
                        <asp:SqlDataSource ID="CupStageRoundsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                            SelectCommand="Nivdal_GetTournamentStageRounds" SelectCommandType="StoredProcedure">   
                            <SelectParameters>
                                <asp:ControlParameter ControlID="StageIdHiddenField" Name="StageId" PropertyName="Value" />
                            </SelectParameters>                     
                        </asp:SqlDataSource>
                    </ItemTemplate>
                    </asp:FormView>
                </asp:Panel>
                <asp:SqlDataSource ID="LeagueOrCupStageAdditionalInfoDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentOnlyGroupInfo" SelectCommandType="StoredProcedure">      
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                    </SelectParameters>              
                </asp:SqlDataSource>
                <asp:Panel ID="GroupsPlayoffsPanel" runat="server" Visible='<%# Eval("TournamentType").ToString() == "3" || Eval("TournamentType").ToString() == "4"  %>'>
                    <%--<asp:Repeater ID="StagesSummaryRepeater" runat="server" DataSourceID="TournamentStagesDataSource">
                        <ItemTemplate>
                            <asp:Label ID="StageTitleLabel" runat="server" SkinID="InfoLabel"
                             Text='<%# Resources.Resource.Global_TournamentStage + " " + Eval("StageNum").ToString() %>'></asp:Label>
                            <br />
                            <asp:Label ID="StageTypeLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("StageTypeName") %>'></asp:Label>
                            <br />
                            <asp:Label runat="server" ID="ExecutionStatus" SkinID="GridLabel" Text='<%# Eval("ExecutionStatusName") %>'></asp:Label>
                            <asp:Label runat="server" ID="CurrentRoundLabel" SkinID="GridLabel" Visible='<%# Eval("ExecutionStatus").ToString() == "2" %>'
                             Text='<%# ", " + Resources.Resource.InternationalCupp_CurrentRoundTitleLabel + ": " + Eval("CurrentRound") %>'></asp:Label>
                            <br />
                            <asp:Label ID="DatesLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("StartDate").ToString() + " - " + Eval("EndDate").ToString() %>'></asp:Label>
                            <asp:Panel ID="PromotionCountPanel" runat="server" Visible='<%# !(bool)Eval("IsLastStage") %>'>
                                <br />
                                <asp:Label runat="server" ID="NumTeamsToPromoteTitle" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_NumberOfTeamsToPromote %>"></asp:Label>
                                <asp:Label runat="server" ID="NumTeamsToPromoteLabel" SkinID="GridLabel" Text='<%# Eval("NumberOfTeamsToPromote") %>'></asp:Label>
                            </asp:Panel>
                        </ItemTemplate>
                        <SeparatorTemplate>
                            <br /><hr /><br />
                        </SeparatorTemplate>
                    </asp:Repeater>--%>
                    <br /><hr /><br />
                    <asp:Repeater ID="TournamentStagesRepeater" runat="server" DataSourceID="TournamentStagesDataSource">
                        <ItemTemplate>
                        <asp:Panel ID="StagePanel" runat="server" Visible='<%# Eval("ExecutionStatus").ToString() != "1" %>'>
                            <asp:Label ID="StageTitleLabel" runat="server" SkinID="SubHeaderLabel"
                             Text='<%# Resources.Resource.Global_TournamentStage + " " + Eval("StageNum").ToString() %>'></asp:Label>
                            &nbsp;-&nbsp;
                            <asp:Label ID="StageTypeLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("StageTypeName") %>'></asp:Label>
                            <br /><br />
                            <asp:HiddenField ID="StageIdHiddenField" runat="server" Value='<%# Eval("StageId") %>' />
                            <asp:Panel ID="GroupsPanel" runat="server" Visible='<%# (Eval("StageType").ToString() == "1") || (Eval("StageType").ToString() == "2")  %>'>
                                
                                <asp:Repeater ID="TournamentGroupsRepeater" runat="server" DataSourceID="TournamentGroupsDataSource">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="TheGroupIdHiddenfield" runat="server" Value='<%# Eval("Id") %>' />
                                        <asp:Label ID="GroupTitleLabel" runat="server" SkinID="InfoLabel"
                                         Text='<%# Resources.Resource.Tournament_Group + " " + Eval("GroupName") %>'></asp:Label>
                                         <br />
                                         <asp:GridView runat="server" ID="GroupTableGrid" AutoGenerateColumns="false" DataSourceID="TournamentGroupsDataSource"
                                          SkinID="Professional">
                                            <Columns>
                                                <asp:TemplateField ItemStyle-Width="10%">
                                                    <ItemTemplate>
                                                        <asp:Label ID="N" runat="server" Text='<%# Eval("Position")%>' SkinID="GridLabel"> </asp:Label> 
                                                        <asp:Image ID="GreenArrowImage" runat="server" ImageUrl="~/Images/Icons/arrowup.png" Visible='<%# Eval("Promotes") %>' />                    
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                 <asp:TemplateField ItemStyle-Width="40%">
                                                    <HeaderTemplate>
                                                        <asp:Label ID="TeamNameLabel" ToolTip="<%$ Resources:Resource, league_TeamNameLabelToolTip %>" runat="server" Text="<%$ Resources:Resource, Global_TeamName %>"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:HyperLink ID="TeamLink" runat="server" Text='<%# Eval("TeamName") %>' SkinID="BlackHyperLinkSkin"
                                                            NavigateUrl='<%# TeamHomePageLink() + Eval("TeamId") %>'></asp:HyperLink>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField ItemStyle-Width="10%">
                                                    <HeaderTemplate>
                                                        <asp:Label ID="GamesTitleLabel" ToolTip="<%$ Resources:Resource, Global_Games %>" runat="server" Text="<%$ Resources:Resource, Global_GamesHeader %>"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="GamesLabel" runat="server" Text='<%# Eval("Round")%>' SkinID="GridLabel"> </asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField ItemStyle-Width="10%">
                                                    <HeaderTemplate>
                                                        <asp:Label ID="PointLabel" ToolTip="<%$ Resources:Resource, Global_Points %>" runat="server" Text="<%$ Resources:Resource, league_PointLabel %>"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Points")%>' SkinID="GridLabel"> </asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField ItemStyle-Width="20%">
                                                    <HeaderTemplate>
                                                        <asp:Label ID="GoalsLabel" ToolTip="<%$ Resources:Resource, Global_Goals %>" runat="server" Text="<%$ Resources:Resource, Global_GoalsHeader %>"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="Label1" runat="server" SkinID="GridLabel"
                                                         Text='<%# Eval("GoalsScored").ToString() + " - " + Eval("GoalsAgainst").ToString() %>' ></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField ItemStyle-Width="10%" HeaderText="<%$ Resources:Resource, Global_Rank %>">
                                                    <ItemTemplate>
                                                        <asp:Label ID="RankLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("Rank") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns> 
                                         </asp:GridView>
                                         <br />

                                         <asp:Hyperlink ID="GroupMatchesLink" runat="server"  Text="<%$ Resources:Resource, Global_Matches %>"
                                          NavigateUrl='<%# "~/TournamentGroup.aspx?Id=" + Eval("Id") %>' SkinID="GreenTitleHyperLink"></asp:Hyperlink>

                                        <asp:SqlDataSource ID="TournamentGroupsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                            SelectCommand="Nivdal_GetTournamentStageGroupTable" SelectCommandType="StoredProcedure">   
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="TheGroupIdHiddenfield" Name="GroupId" PropertyName="Value" />
                                            </SelectParameters>                     
                                        </asp:SqlDataSource>
                                    </ItemTemplate>
                                    <SeparatorTemplate><br /><hr /><br /></SeparatorTemplate>
                                </asp:Repeater>
                                <asp:SqlDataSource ID="TournamentGroupsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                    SelectCommand="Nivdal_GetTournamentStageGroups" SelectCommandType="StoredProcedure">   
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="StageIdHiddenField" Name="StageId" PropertyName="Value" />
                                    </SelectParameters>                     
                                </asp:SqlDataSource>
                            </asp:Panel>
                            <asp:Panel ID="PlayoffPanel" runat="server" Visible='<%# Eval("StageType").ToString() == "3" %>'>
                                <asp:HiddenField ID="GroupHiddenField" runat="server" Value='<%# Eval("GroupId") %>' />
                                <asp:Repeater ID="StageRoundsRepeater" runat="server" DataSourceID="CupStageRoundsDataSource">
                                    <ItemTemplate>
                                        <asp:Label ID="RoundDateLabel" runat="server" SkinID="GridLabel"
                                         Text='<%# RoundLabelText(Eval("RoundNumber").ToString(), Eval("Date").ToString(), Eval("SpecialName").ToString()) %>'></asp:Label>
                                        <asp:HiddenField ID="RoundHiddenField" runat="server" Value='<%# Eval("RoundNumber") %>' />
                                        <br />
                                        <asp:GridView ID="RoundMatchesGridview" runat="server" DataSourceID="TournamentRoundMatches"
                                         AutoGenerateColumns="false" SkinID="Professional">
                                         <Columns>
                                               <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:HyperLink ID="MatchLink" runat="server" SkinID="BlackHyperLinkSkin" Text='<%# Eval("MatchTitle") %>'
                                                     NavigateUrl='<%# "~/MatchPage.aspx?MatchId=" + Eval("MatchId") %>'></asp:HyperLink>
                                                </ItemTemplate>
                                               </asp:TemplateField>                                            
                                               <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="ResultLabel" SkinID="GridLabel" Text='<%# Eval("Result") %>'></asp:Label>
                                                </ItemTemplate>
                                               </asp:TemplateField>
                                         </Columns>
                                         </asp:GridView>
                                         <asp:SqlDataSource ID="TournamentRoundMatches" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                        SelectCommand="Nivdal_GetTournamentStageRoundMatches" SelectCommandType="StoredProcedure">   
                                        <SelectParameters>
                                            <asp:ControlParameter ControlID="GroupHiddenField" Name="GroupId" PropertyName="Value" />
                                            <asp:ControlParameter ControlID="RoundHiddenField" Name="Round" PropertyName="Value" />
                                        </SelectParameters>                     
                                    </asp:SqlDataSource>
                                    </ItemTemplate>
                                    <SeparatorTemplate><br /></SeparatorTemplate>
                                </asp:Repeater>
                                <asp:SqlDataSource ID="CupStageRoundsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                    SelectCommand="Nivdal_GetTournamentStageRounds" SelectCommandType="StoredProcedure">   
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="StageIdHiddenField" Name="StageId" PropertyName="Value" />
                                    </SelectParameters>                     
                                </asp:SqlDataSource>
                            </asp:Panel>
                        </asp:Panel>
                        </ItemTemplate>     
                        <SeparatorTemplate><br /><hr /><br /></SeparatorTemplate>                   
                    </asp:Repeater>
                    
                    
                    
                </asp:Panel>
                <asp:Panel ID="BonusPromotionsPanel" runat="server" Visible='<%# Eval("TournamentType").ToString() == "5" %>'>
                    &nbsp;
                </asp:Panel>
                <br />
                <asp:HyperLink ID="ScorersHyperlink" runat="server" SkinID="GreenTitleHyperLink"
                 Text="<%$ Resources:Resource, league_TopScorersTitleLabelText %>" Visible='<%# ((Eval("ExecutionStatus").ToString() == "2") || (Eval("ExecutionStatus").ToString() == "3")) %>'
                 NavigateUrl='<%# "~/TournamentScorers.aspx?TournamentId=" + Eval("TournamentId") %>'></asp:HyperLink>
            </asp:Panel>
            <asp:Panel ID="SignupPanel" runat="server" Visible='<%# (Eval("ExecutionStatus").ToString() == "1") %>'>
                <asp:Panel ID="ActualSignupPanel" runat="server" Visible='<%# Eval("CanSignup") %>'>
                    <div id="tournament_signup_area">
                        <asp:Label ID="PasswordTitleLabel" runat="server" SkinID="InfoLabel" Visible='<%# Eval("PasswordNeeded") %>'
                        Text="<%$ Resources:Resource, Register_PasswordRequired %>" ></asp:Label>
                        <asp:TextBox ID="PasswordTextBox" runat="server" MaxLength="10"  Visible='<%# Eval("PasswordNeeded") %>' TextMode="SingleLine"></asp:TextBox>
                        <br />
                        <asp:Button ID="SignupButton" runat="server" CssClass="GreenSmallButtonStyle" Text="<%$ Resources:Resource, Tournament_SignUpButtonText %>" OnClick="SignupForTournament" />
                    </div>
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                        <ProgressTemplate>
                            <div class="ajaxloader">
                                <asp:Image ID="ProgressImage" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
                            </div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </asp:Panel>
                <asp:Panel ID="CannotSignup" runat="server" Visible='<%# !(bool)Eval("CanSignup") && !(bool)Eval("CanSignOut") %>'>
                    <asp:Label ID="CannotSignLabel" runat="server" SkinID="GridLabel" Text="<%$ Resources:Resource, Tournament_CannotSignUp %>"></asp:Label>
                </asp:Panel>
                <asp:Panel ID="SignOutPanel" runat="server" Visible='<%# Eval("CanSignOut") %>'>
                    <br />
                    <asp:Button ID="SignOutButton" runat="server" Text="<%$ Resources:Resource, Tournament_WithdrawFromTournament %>"
                     CssClass="GreenSmallButtonStyle" OnClick="WithdrawFromTournament" />
                </asp:Panel>
                <br /><br />
                <asp:HiddenField ID="RoleHF" runat="server" Value='<%# Eval("UserRole") %>' />
                <asp:Repeater ID="ApprovedTeamsRepeater" runat="server" DataSourceID="ApprovedTeamsDataSource" OnItemCommand="RemoveUser">
                <HeaderTemplate>
                    <asp:Label ID="SigedTeams" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_SignedTeamsListTitle %>"></asp:Label>
                    <br />
                    <table cellpadding="3">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr><td>
                    <asp:HyperLink ID="TeamLink" runat="server" Text='<%# Eval("TeamName") %>'  SkinID="GreenTitleHyperLink"
                    NavigateUrl='<%# TeamHomePageLink() + Eval("TeamId") %>'></asp:HyperLink>
                    </td><td>
                    <asp:ImageButton ID="RemoveImageButton" runat="server" CommandName="Remove" CommandArgument='<%# Eval("ApplicationId") %>' ImageURL="~/Images/Icons/delete.png" ToolTip="<%$ Resources:Resource, Global_Delete %>"
                     Visible='<%# ((Container.Parent.Parent.FindControl("RoleHF") as HiddenField).Value == "1") || ((Container.Parent.Parent.FindControl("RoleHF") as HiddenField).Value == "2") %>' />
                     </td></tr>
                </ItemTemplate>
                
                <FooterTemplate></table></FooterTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="ApprovedTeamsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentTeamsByStatus" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        <asp:Parameter Name="ApprovalStatus" DefaultValue="2" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br /><br />
                
                <asp:Repeater ID="WaitingDirectorApprovalTeams" runat="server" DataSourceID="WaitingDirectorTeamsDataSource">
                <HeaderTemplate>
                    <asp:Label ID="WaitingTeams" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_WaitingTeamsListTitle %>"></asp:Label>
                    <br />
                    <table cellpadding="3">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr><td>
                    <asp:HyperLink ID="TeamLink" runat="server" Text='<%# Eval("TeamName") %>'  SkinID="GreenTitleHyperLink"
                    NavigateUrl='<%# TeamHomePageLink() + Eval("TeamId") %>'></asp:HyperLink>
                    </td><td>
                    <asp:HiddenField ID="ApplicationIdHF" runat="server" Value='<%# Eval("ApplicationId") %>' />
                    <asp:CheckBox ID="ApproveCheckBox" runat="server"
                    Visible='<%# ((Container.Parent.Parent.FindControl("RoleHF") as HiddenField).Value == "1") || ((Container.Parent.Parent.FindControl("RoleHF") as HiddenField).Value == "2") %>' />
                    </td></tr>
                </ItemTemplate>
                <FooterTemplate></table></FooterTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="WaitingDirectorTeamsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentTeamsByStatus" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        <asp:Parameter Name="ApprovalStatus" DefaultValue="1" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                <asp:Button ID="ApproveSelectedButton" runat="server" CssClass="GreenSmallButtonStyle" Text="<%$ Resources:Resource, Admin_ApproveSelected %>" OnClick="ApproveSelectedTeams"
                 Visible='<%# (Eval("UserRole").ToString() == "1") || (Eval("UserRole").ToString() == "2")  %>' />
                <asp:Button ID="DeclineSelectedButton" runat="server" CssClass="GreySmallButtonStyle" Text="<%$ Resources:Resource, InternalTeamMessages_DeleteSelectedButtonText %>" 
                OnClick="DeclinewSelectedTeams" Visible='<%# (Eval("UserRole").ToString() == "1") || (Eval("UserRole").ToString() == "2")  %>' />

                <br /><br />
                <asp:Repeater ID="WaitingListRepeater" runat="server" DataSourceID="WaitingListDataSource">
                <HeaderTemplate>
                    <asp:Label ID="WaitingTeams" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_WaitingLisTeamsListTitle %>"></asp:Label>
                    <br />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:HyperLink ID="TeamLink" runat="server" Text='<%# Eval("TeamName") %>' SkinID="GreenTitleHyperLink" 
                    NavigateUrl='<%# (IsNationalTeams() ? "~/NationalTeam.aspx?Id=" : "~/TeamHomePage.aspx?TeamId=") + Eval("TeamId") %>'></asp:HyperLink>
                </ItemTemplate>
                <SeparatorTemplate>,</SeparatorTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="WaitingListDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="Nivdal_GetTournamentTeamsByStatus" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        <asp:Parameter Name="ApprovalStatus" DefaultValue="3" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
            </asp:Panel>
            <asp:Panel ID="ManagementPanel" runat="server" Visible='<%# ((Eval("ExecutionStatus").ToString() == "1") && ((Eval("UserRole").ToString() == "1") || (Eval("UserRole").ToString() == "2")))  %>'>
                <hr /><br />
                <asp:Label ID="ManagementPanelTitleLabel" runat="server" Text="<%$ Resources:Resource, Tournament_ManagementPanel %>" SkinID="SubHeaderLabel"></asp:Label>
                <br /><hr /><br />
                <%--Start the rournament--%>    
                <asp:Button ID="StartTournamentButton" runat="server" Text="<%$ Resources:Resource, Tournament_StartTournament %>" 
                 CssClass="GreenSmallButtonStyle" OnClick="StartTournament" message="<%$ Resources:Resource, Tournament_AreYouSureStartTournament %>"
                 OnClientClick='return confirm(this.getAttribute("message"))' />
                 
                <br /><hr /><br />
                <%--Choose prices--%>
                <asp:Panel ID="TournamentPrizesChoosePanel" runat="server" Visible='<%# Eval("PrizesAvailable") %>'>
                    <asp:Label ID="TournamentPrizesTitle" runat="server" Text="<%$ Resources:Resource, Tournament_TournamentPricesTitle %>" SkinID="InfoLabel"></asp:Label>
                    <br />
                    <asp:Repeater ID="PrizesSetRepeater" runat="server" DataSourceID="PrizesSetsDataSource">
                    <HeaderTemplate><table></HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                        <td style="vertical-align:middle;">
                            <asp:RadioButton ID="SelectedRB" runat="server" Checked='<%# Eval("IsSelected") %>' GroupName="PrizesSets" onclick='<%# "PrizesCheck(\"" + Eval("Id") + "\")" %>' />
                            <asp:HiddenField ID="OptionIdHF" runat="server" Value='<%# Eval("Id") %>' />
                        </td>
                        <td>
                            <asp:Image ID="Place1Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place1") %>' ToolTip="#1" Visible='<%# Eval("Place1").ToString().Length > 5 %>' />
                            <asp:Image ID="Place2Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place2") %>' ToolTip="#2" Visible='<%# Eval("Place2").ToString().Length > 5 %>' />
                            <asp:Image ID="Place3Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place3") %>' ToolTip="#3" Visible='<%# Eval("Place3").ToString().Length > 5 %>' />
                            <asp:Image ID="Place4Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place4") %>' ToolTip="#4" Visible='<%# Eval("Place4").ToString().Length > 5 %>' />
                            <asp:Image ID="Place5Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place5") %>' ToolTip="#5" Visible='<%# Eval("Place5").ToString().Length > 5 %>' />
                            <asp:Image ID="ScorerImage" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Scorer") %>' ToolTip="<%$ Resources:Resource, Tournament_TopScorer %>" Visible='<%# Eval("Scorer").ToString().Length > 5 %>' />
                            <asp:Image ID="AssisterImage" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Assister") %>' ToolTip="<%$ Resources:Resource, Tournament_MostAssists %>" Visible='<%# Eval("Assister").ToString().Length > 5 %>' />
                        </td>
                        </tr>
                    </ItemTemplate>        
                    <FooterTemplate></table></FooterTemplate>        
                    </asp:Repeater>
                    <asp:SqlDataSource ID="PrizesSetsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="Nivdal_GetTournamentPrizesOptions" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="TournamentIdHiddenField" PropertyName="Value" Name="TournamentId" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <br />
                    <asp:Button ID="SetPrizesSetButton" runat="server" CssClass="GreenSmallButtonStyle" OnClick="SetPrizes" Text="<%$ Resources:Resource, Global_Submit %>" />
                    <br /><hr /><br />
                </asp:Panel>
                <%--add tournament directors--%>
                <asp:Label ID="AddTournamentDirectorTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Tournament_AddTournamentDirector %>"></asp:Label>
                <asp:TextBox ID="TournamentDirectorTeamIdTextBox" runat="server" MaxLength="12" TextMode="SingleLine" Width="100"></asp:TextBox>
                <asp:Button ID="AddTournamentDirectorButton" runat="server" CssClass="GreenSmallButtonStyle" OnClick="AddDirector" Text="<%$ Resources:Resource, Global_Add %>" />
                <br /><hr /><br />
                <%--change password--%>
                <asp:Label ID="SignupTypeTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, CreateTournament_SignupTypeTitle %>"></asp:Label>
                <br />
                <asp:RadioButton ID="ClearSignupRadioButton" runat="server" Checked='<%# Eval("SignupPassword").ToString().Length == 0 %>' 
                Text="<%$ Resources:Resource, CreateTournament_SignupTypeFree %>" GroupName="SignupType" CssClass="NewsItemStyle"/>
                <br />
                <asp:RadioButton ID="PasswordSignupRadioButton" runat="server" GroupName="SignupType" CssClass="NewsItemStyle"
                 Text="<%$ Resources:Resource, CreateTournament_SignupTypePassword %>" Checked='<%# Eval("SignupPassword").ToString().Length > 0 %>' />
                 
                <asp:TextBox ID="TournamentPasswordTextBox" runat="server" Width="100" MaxLength="10" Text='<%# Eval("SignupPassword") %>'></asp:TextBox>

                <asp:ImageButton ID="GeneratepasswordButton" runat="server" ImageUrl="~/Images/Icons/UnbeatenSeason.png"
                    ToolTip="<%$ Resources:Resource, CreateTournament_GeneratePasswordButttonText %>" OnClientClick="GeneratePassword(); return false;" />

                <asp:Label ID="PleaseChoosePasswordTitleLabel" runat="server" SkinID="RedConfirmLabel"
                    Text="<%$ Resources:Resource, CreateTournament_PleaseSetPasswordText %>" Visible="false"></asp:Label>
                <br />
                <asp:Button ID="SetPasswordButton" runat="server" CssClass="GreenSmallButtonStyle" 
                Text="<%$ Resources:Resource, Global_Set %>" OnClick="SetPassword" />
                <br /><hr /><br />
                <asp:Button ID="DeleteTournamentButton" runat="server" Text="<%$ Resources:Resource, Tournament_DeleteTournament %>" message="<%$ Resources:Resource, Tournament_AreYouSureDelete %>"
                  CssClass="GreySmallButtonStyle" OnClick="DeleteTournament" OnClientClick='return confirm(this.getAttribute("message"))' />
            </asp:Panel>
            </div>
            </div>            
        </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="TournamentInfoDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetTournamentInfo" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="TournamentDatesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetTournamentDates" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="FriendlyWeeksDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetTournamentFriendlyWeeks" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="TournamentStagesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetTournamentStages" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
    <asp:Label ID="PageNameLabel" runat="server" CssClass="PageNameContentStyle"></asp:Label>
</asp:Content>
